{extend name='admin@public/content'}

{block name="content"}
<form autocomplete="off" onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" class='form-horizontal layui-form padding-top-20'>

    <div class="form-group">
        <label class="col-sm-2 control-label">文章名称</label>
        <div class='col-sm-8'>
            <input autofocus name="title" value='{$vo.title|default=""}' required="required" title="请输入文章名称" placeholder="请输入文章名称" class="layui-input">
        </div>
    </div>

    <!--{if !empty($cates)}-->
    <div class="form-group">
        <label class="col-sm-2 control-label">文章分类</label>
        <div class='col-sm-8'>
            <select required class="layui-select full-width" name="type" lay-filter="type">
                {foreach $cates as $cate}
                <!--{eq name='$cate.id' value='$vo.type|default=0'}-->
                <option selected="selected" value="{$cate.id}">{$cate.title}</option>
                <!--{else}-->
                <option value="{$cate.id}">{$cate.title}</option>
                <!--{/eq}-->
                {/foreach}
            </select>
        </div>
    </div>
    <!--{/if}-->

    <div class="form-group">
        <label class="col-sm-2 control-label label-required">图片</label>
        <div class='col-sm-8'>
            <table class="layui-table background-item margin-none" lay-size="sm" lay-skin="nob">
                <thead>
                <tr>
                    <td>文章图片</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td class="text-top" style="width:100px">
                        <input type="hidden" name="image" value="{$vo.image|default=''}">
                        <script>$('[name=image]').uploadOneImage()</script>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">排序</label>
        <div class='col-sm-8'>
            <input name="sort" value='{$vo.sort|default="0"}'  title="请输入排序值" placeholder="请输入排序值" class="layui-input">
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label label-required">文章内容</label>
        <div class='col-sm-8'>
            <textarea name="content">{$vo.content|default=''|htmlspecialchars_decode}</textarea>
        </div>
    </div>

    <div class="hr-line-dashed"></div>

    <div class="col-sm-7 col-sm-offset-2">
        <div class="layui-form-item text-center">
            {if !empty($vo.id)}<input type="hidden" name="id" value="{$vo.id}">{/if}
            <button class="layui-btn" type="submit">保存</button>
            <button class="layui-btn layui-btn-danger" type='button' onclick="window.history.back()">取消</button>
        </div>
    </div>

    <script>
        require(['jquery', 'ckeditor', 'angular'], function () {
            window.form.render();
            window.createEditor('[name="content"]', {height: 500});
        });

    </script>

    <style>
        .background-item {
            padding: 15px;
            background: #efefef;
        }

        .background-item thead tr {
            background: #e0e0e0
        }
    </style>
</form>
{/block}